/*
 * @Author: Seon.Hu SeonHu@126.com
 * @Date: 2022-02-13 16:35:34
 * @LastEditors: Seon.Hu SeonHu@126.com
 * @LastEditTime: 2023-07-10 14:57:40
 * @FilePath: \app-pda\apis\sms\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import request from '@/utils/http/uni-ajax';

/** 短信模块URL枚举 */
const Api = {
	/** 读取验证码短信记录列表 */
	ReadCaptchaRecords: '/api/sms/readCaptchaRecords',

	/** 发送短信验证码 */
	SendVerifyCode: '/api/sms/sendVerifyCode',

	/** 校验短信验证码，只作为前端Ajax验证，验证成功不确认验证码，验证码仍需传到后端进行再次验证 */
	CheckVerifyCode: '/api/sms/checkVerifyCode',
	/** 验证短信验证码 */
	ConfirmVerifyCode: '/api/sms/confirmVerifyCode'
}

/**
 * 发送短信验证码
 * @param dto 手机号码DTO
 * @param mode 错误消息模型
 */
export function sendSmsVerifyCode(dto, mode = 'message') {
	return request.post({
		url: Api.SendVerifyCode,
		data: dto,
		requestOptions: {
			errorMessageMode: mode
		}
	});
}

/**
 * 校验短信验证码，只作为前端Ajax验证，验证成功不确认验证码，验证码仍需传到后端进行再次验证
 * @param dto 短信验证码校验DTO
 * @param mode 错误消息模型
 */
export function checkSmsVerifyCode(dto, mode = 'none') {
	return request.post({
		url: Api.CheckVerifyCode,
		data: dto,
		requestOptions: {
			errorMessageMode: mode
		}
	});
}

/**
 * 验证短信验证码
 * @param dto 短信验证码确认DTO
 * @param mode 错误消息模型
 */
export function confirmSmsVerifyCode(dto, mode = 'message') {
	return request.post({
		url: Api.ConfirmVerifyCode,
		data: dto,
		requestOptions: {
			errorMessageMode: mode
		}
	});
}
